/**
 * 由于调用setReadStatus接口被后端废弃掉了，所以这个hooks也废弃使用
 * 这个hooks干嘛用的也不知道。。
 */
import React from 'react';
import { useRequest, defaultFormatResult } from '@/hooks';
import { setReadStatus } from '@/services/message';

// 调岗 8, 转正 9, 离职 10, 审批 12;
export const readStatusMap = {
    TRANSFER: 8,
    REGULAR: 9,
    LEAVE: 10,
    APPLY: 12
};

export const useSetReadStatus = ({ auto = true, type, id }) => {
    const { loading, run } = useRequest(setReadStatus, {
        manual: true,
        // ready: !!id, // 手动ready无用
        ...defaultFormatResult
    });
    React.useEffect(() => {
        if (auto && id) run(id, type);
    }, [auto, id, type]);
    return [run, loading, readStatusMap];
};
